package cn.tangsihai.basic.interceptor.config;

import cn.tangsihai.basic.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 登录拦截器配置类
 */
@Configuration // 标志此类为配置类
public class LoginConfigurer implements WebMvcConfigurer {
    @Autowired
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor) // 注册拦截器
                .addPathPatterns("/**") // 拦截所有
                // 放行的路径
                .excludePathPatterns("/login/**", "/user/register",
                        "/verifycode/smsCode", "/common/fastDfs",
                        "/shop/settlement", "/pay/calback");
    }
}
